<!--#
layout("/layouts/platform.html"){
#-->
<div id="app"  v-cloak>
    <el-row class="header navbar bg-white">
        <div class="btn-group tool-button" style="line-height: 50px;">
            样品编号或名称：<el-input placeholder="样品编号或名称" v-trim v-model="pageForm.searchKeyword"  size="mini" style="width:180px;" clearable></el-input>
                <template v-if="operation=='rwfp'">
                    分配状态：<el-select v-trim v-model="pageForm.fpzt" placeholder="分配状态" size="mini" style="width:180px;" @change="showFprq">
                        <el-option label="待分配" value="0"></el-option>
                        <el-option label="已分配" value="1"></el-option>
                    </el-select>
                </template>
                <template v-if="pageForm.fpzt==1 || operation=='rwch'">
                    检验批次：<el-date-picker type="datetime"  v-model="pageForm.jypcsk" value-format="yyyy-MM-dd HH:mm:ss" size="mini"  style="width: 180px;"></el-date-picker>至
                    <el-date-picker type="datetime"  v-model="pageForm.jypcjs" value-format="yyyy-MM-dd HH:mm:ss" size="mini" style="width: 180px;"></el-date-picker>
                </template>
            <el-button slot="append" icon="el-icon-search" size="mini" @click="doSearch" circle></el-button>
        </div>
        <div class="pull-right offscreen-right" style="margin-right: 20px;line-height: 50px;">
            <el-tooltip v-if="operation=='rwfp' && pageForm.fpzt==0" class="item" effect="dark" content="批量分配">
                <el-button type="primary" icon="el-icon-thumb" size="mini" @click="tofps" circle></el-button>
            </el-tooltip>
            <el-tooltip v-if="(operation=='rwfp' && pageForm.fpzt==1) || operation=='rwch'" class="item" effect="dark" content="批量撤回">
                <el-button type="primary" icon="el-icon-refresh-right" size="mini" @click="tochs" circle></el-button>
            </el-tooltip>
            <el-tooltip v-if="(operation=='rwfp' && pageForm.fpzt==1)" class="item" effect="dark" content="导出样品检测任务分配单">
                <el-button type="primary" icon="el-icon-download" size="mini" @click="dofpsExcel('all')" circle></el-button>
            </el-tooltip>
        </div>
    </el-row>
    <el-row class="el-table-container">
        <el-table ref="multipleTable" :data="tableData" @sort-change='pageOrder' row-key="id" height="520"  border size="small" header-align="center"  style="width: 100%" @selection-change="handleSelectionChange" row-key="id">
            <el-table-column v-if="operation!='rwrl'" type="selection" :selectable="checkSelect" reserve-selection="true" label="选择" width="55px;" header-align="center" align="center"></el-table-column>
            <el-table-column fixed="left" prop="userOnline" label="操作" width="80" header-align="center" align="center">
                <template slot-scope="scope">
                    <el-dropdown @command="dropdownCommand">
                        <el-button size="mini"><i class="ti-settings"></i><span class="ti-angle-down"></span></el-button>
                        <el-dropdown-menu slot="dropdown">
                            <!--#if(@shiro.hasPermission("bus.rwgl.tofp")){#-->
                            <template v-if="operation=='rwfp'&&pageForm.fpzt==0">
                                <el-dropdown-item divided :command="{type:'tofp',id:scope.row.id,ypbh:scope.row.ypbh}">分配</el-dropdown-item>
                            </template>
                            <!--#}#-->
                            <!--#if(@shiro.hasPermission("bus.rwgl.torl")){#-->
                            <template v-if="operation=='rwrl'">
                                <el-dropdown-item divided :command="{type:'torl',id:scope.row.id,ypbh:scope.row.ypbh}">认领</el-dropdown-item>
                            </template>
                            <!--#}#-->
                            <!--#if(@shiro.hasPermission("bus.rwgl.toch")){#-->
                            <template v-if="operation=='rwch' || (operation=='rwfp' && pageForm.fpzt==1)">
                                <el-dropdown-item divided :command="{type:'toch',id:scope.row.id,ypbh:scope.row.ypbh}">撤回</el-dropdown-item>
                            </template>
                            <!--#}#-->
                            <el-dropdown-item  :command="{type:'detail',id:scope.row.id}">详情</el-dropdown-item>
                            <!--<template v-if="pageForm.fpzt==1">
                                <el-dropdown-item  :command="{type:'createCirculation',id:scope.row.id}">流转单</el-dropdown-item>
                            </template>-->
                        </el-dropdown-menu>
                    </el-dropdown>
                </template>
            </el-table-column>
            <el-table-column fixed="left" sortable="custom" prop="ypbh" label="样品编号" width="120px;" header-align="center" show-overflow-tooltip></el-table-column>
            <el-table-column fixed="left" sortable="custom" prop="bgbh" label="报告编号" width="150px;" header-align="center" show-overflow-tooltip></el-table-column>
            <el-table-column v-if="operation=='rwch'"  prop="nextspr" label="编制人" width="150px;" header-align="center" show-overflow-tooltip></el-table-column>

            <el-table-column prop="lczt" label="检验状态" width="80px;" header-align="center"  show-overflow-tooltip>
                <template slot-scope="scope" ><span :class="'statusCss-'+scope.row.lczt"><i :class="'el-icon-'+scope.row.lczt"/>{{getDict(scope.row.lczt,allMap.lcztMap)}}</span></template>
            </el-table-column>
            <el-table-column prop="lzzt" label="流转状态" width="120px;" header-align="center"  show-overflow-tooltip>
                <template slot-scope="scope" >
                    <span :class="'lzstatusCss-'+scope.row.lzzt"><i :class="'lzel-icon-'+scope.row.lzzt"/>{{getDict(scope.row.lzzt,allMap.lzztMap)}}</span>
                    <span v-if="scope.row.lzzt<3"><span v-if="scope.row.status=='0'">(待接收)</span>
                    <span v-if="scope.row.status=='1'">(已接收)</span>
                    <span v-if="scope.row.status=='-1'">(已拒收)</span></span></template>
                </template>
            </el-table-column>
            <el-table-column sortable="custom"  prop="ypmc" label="产品名称" min-width="150px;" header-align="center" show-overflow-tooltip></el-table-column>
            <el-table-column sortable="custom" prop="jylx" label="检验类别" width="100px;" header-align="center" align="center" show-overflow-tooltip>
                <template slot-scope="scope" >{{getDict(scope.row.jylx,allMap.jylxMap)}}</template>
            </el-table-column>
            <el-table-column sortable="custom" prop="jyks" label="检验部门" width="100px;" header-align="center" align="center" show-overflow-tooltip></el-table-column>
            <el-table-column sortable="custom" prop="jypc" label="检验批次" width="100px;" header-align="center" align="center" show-overflow-tooltip></el-table-column>
            <el-table-column prop="wtdw" label="委托单位" min-width="180px;" header-align="center" align="center" show-overflow-tooltip></el-table-column>
            <!--<el-table-column prop="ggxh" label="规格型号" width="100px;" header-align="center" align="center" show-overflow-tooltip></el-table-column>
            <el-table-column prop="scrqpc" label="生产日期/批号" width="120px;" header-align="center" align="center" show-overflow-tooltip></el-table-column>
            <el-table-column prop="sb" label="商标" width="100px;" header-align="center" align="center" show-overflow-tooltip></el-table-column>-->
            <el-table-column sortable="custom" prop="wcqx" label="完成期限" width="100px;" header-align="center" align="center" show-overflow-tooltip></el-table-column>
            <el-table-column prop="" label="剩余时间" min-width="100px;" header-align="center" align="center" show-overflow-tooltip>
                <template slot-scope="scope" ><span :id="'foot'+scope.$index">{{getDay(scope.row.wcqx,scope.$index)}}</span></template>
            </el-table-column>
        </el-table>
    </el-row>
    <el-row class="el-pagination-container">
        <el-pagination @size-change="pageSizeChange" @current-change="pageNumberChange" :current-page="pageForm.pageNumber" :page-sizes="[10, 20, 30, 50]"
                :page-size="pageForm.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="pageForm.totalCount">
        </el-pagination>
    </el-row>
    </el-dialog>
    <el-drawer :wrapperClosable="false" title="详情" :visible.sync="drawer" direction="rtl" size="80%" @opened="openIframe" destroy-on-close>
        <iframe id="iframeDetail"  src="" width="100%" height="100%" frameborder="0" marginheight="0" ></iframe>
    </el-drawer>

    <el-dialog :close-on-click-modal="false" title="任务分配" :visible.sync="fpDialogVisible" width="70%">
        <el-form :model="formData" ref="fpForm"  size="mini" label-width="120px" >
            <el-form-item prop="ypbh" label="样品编号">
                <el-link type="primary" size="mini" @click="dropdownCommand({type:'detail',id:formData.id})">{{formData.ypbh}}</el-link>
            </el-form-item>
            <el-form-item prop="nextsprIds" label="报告编制人员" :rules="{required: true, message: '报告编制人员', trigger: ['blur', 'change']}">
                <el-cascader v-model="formData.nextsprIds" :options="allMap.userOptions" :props="{ multiple: true }" ref="nextsprCascader"   style="width:100%;"></el-cascader>
            </el-form-item>
            <!--<el-form-item prop="jyryIds" label="样品检验人员">
                <el-cascader v-model="formData.jyryIds" :options="allMap.userOptions" :props="{ multiple: true }" ref="jyryCascader"  style="width:100%;"></el-cascader>
            </el-form-item>-->

            <el-row :gutter="20">
                <el-col :span="16">
                    <el-form-item prop="jyxm" label="检验项目" ><!--:rules="{required: true, message: '检验项目', trigger: ['blur', 'change']}"-->
                        <el-input maxlength="200" readonly v-model="formData.jyxm" type="textarea" size="mini" rows="3"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="8" style="">
                    <el-button type="primary" size="mini" @click="openIns(formData)" plain>选择检验项目</el-button>
                </el-col>
            </el-row>
            <el-form-item prop="jyyj" label="检验依据" ><!--:rules="{required: true, message: '检验依据', trigger: ['blur', 'change']}"-->
                <el-input maxlength="200" v-model="formData.jyyj" type="textarea" size="mini" rows="3"></el-input>
            </el-form-item>
            <el-row :gutter="20">
                <el-col :span="8">
                    <el-form-item prop="jyfy" label="检验费用（元）">
                        <el-input-number maxlength="30"  v-trim v-model="formData.jyfy"  style="width:180px;"></el-input-number>
                    </el-form-item>
                </el-col>
                <el-col :span="8">
                    <el-form-item prop="wcqx" label="完成期限" :rules="{required: true, message: '完成期限', trigger: ['blur', 'change']}">
                        <el-date-picker type="date"  v-trim v-model="formData.wcqx" value-format="yyyy-MM-dd" style="width: 180px;"></el-date-picker>
                    </el-form-item>
                </el-col>
                <el-col :span="8">
                    <el-form-item prop="limitDay" label="检验时限">
                        <el-input-number maxlength="30"  v-trim v-model="formData.limitDay"  style="width:180px;"></el-input-number> 个工作日
                    </el-form-item>
                </el-col>
            </el-row>
            <el-form-item prop="" label="样品检验人员">
                <el-table :data="formData.yjbxxjyxm"  border size="small" header-align="center"  style="width: 100%" >
                    <el-table-column  prop="inspectionStandard" label="检验标准" min-width="110px;" header-align="center" align="center" show-overflow-tooltip></el-table-column>
                    <el-table-column   prop="inspectionItemName" label="检验项目" min-width="110px;" header-align="center" align="center" show-overflow-tooltip></el-table-column>
                    <el-table-column prop="inspectorUnitId"  label="检验人员" min-width="200px">
                        <template slot-scope="scope">
                            <el-row>
                                <el-col :span="12">
                                    <el-form-item :prop="'yjbxxjyxm.'+scope.$index+'.inspectorUnitId'"
                                                  :rules="{required: true, message: '部门', trigger: ['blur', 'change']}">
                                        <el-select v-model="scope.row.inspectorUnitId" @change="changeUnit(scope.$index,scope.row)" placeholder="部门" show size="mini">
                                            <el-option v-for="map in allMap.unitOptions" :key="map.value" :label="map.label" :value="map.value"> </el-option>
                                        </el-select>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="12">
                                    <el-form-item :prop="'yjbxxjyxm.'+scope.$index+'.inspectorUserId'"
                                                  :rules="{required: true, message: '人员', trigger: ['blur', 'change']}">
                                        <el-select v-model="scope.row.inspectorUserId" @change="changeUser(scope.$index,scope.row)"
                                                   @visible-change="getUsers(scope.row)" placeholder="人员" show size="mini" multiple>
<!--
                                            <el-option v-if="scope.row.inspectorUserId" :label="scope.row.inspectorUserName" :value="scope.row.inspectorUserId" > </el-option>
-->
                                            <el-option v-for="map in scope.row.itemUserOptions" :key="map.id" :label="map.username" :value="map.id"> </el-option>
                                        </el-select>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                        </template>
                    </el-table-column>
                    <el-table-column prop="inspectorMethod" label="检验方法" min-width="120" header-align="center" align="center" show-overflow-tooltip></el-table-column>
                </el-table>
            </el-form-item>
            <el-form-item prop="spyj" label="意见">
                <el-input maxlength="200"  v-trim v-model="formData.spyj" type="textarea" size="mini" rows="3"></el-input>
            </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer"><el-button @click="fpDialogVisible = false">取 消</el-button><el-button type="primary" @click="dofp">分 配</el-button></span>
    </el-dialog>

    <el-dialog :close-on-click-modal="false" title="批量分配" :visible.sync="fpsDialogVisible" width="70%">
        <el-form :model="formData" ref="fpsForm"  size="mini" label-width="120px" >
            <el-form-item prop="jypc" label="检验批次" :rules="{required: true, message: '检验批次', trigger: ['blur', 'change']}">
                <el-date-picker type="datetime"  v-trim v-model="formData.jypc" value-format="yyyy-MM-dd HH:mm:ss" style="width: 180px;"></el-date-picker>
            </el-form-item>
            <el-form-item prop="spyj" label="意见">
                <el-input maxlength="200"  v-trim v-model="formData.spyj" type="textarea" size="mini" rows="3"></el-input>
            </el-form-item>
            <el-tabs v-model="activeName" type="card" editable @edit="handleTabsEdit">
                <template v-for="(obj,objIndex) in formData.listObj">
                  <el-tab-pane :label="obj.ypbh" :name="obj.ypbh" >
                    <el-form-item label="样品编号">
                        <el-link type="primary" size="mini" @click="dropdownCommand({type:'detail',id:obj.jbxxId})">{{obj.ypbh}}</el-link>
                    </el-form-item>
                    <el-form-item label="报告编制人员"
                                  :prop="'listObj.'+objIndex+'.nextsprIds'"
                                  :rules="{required: true, message: '报告编制人员', trigger: ['blur', 'change']}">
                        <el-cascader v-model="obj.nextsprIds" :options="obj.userOptions" :props="{ multiple: true }" style="width:100%;" @change="getNextsprs(obj)"></el-cascader>
                    </el-form-item>
                    <el-row :gutter="20">
                          <el-col :span="16">
                              <el-form-item :prop="'listObj.'+objIndex+'.jyxm'" label="检验项目" ><!--:rules="{required: true, message: '检验项目', trigger: ['blur', 'change']}"-->
                                  <el-input maxlength="200"  v-model="obj.jyxm" type="textarea" size="mini" rows="3"></el-input>
                              </el-form-item>
                          </el-col>
                          <el-col :span="8" style="">
                              <el-button type="primary" size="mini" @click="openIns(obj)" plain>选择检验项目</el-button>
                          </el-col>
                    </el-row>
                    <el-form-item :prop="'listObj.'+objIndex+'.jyyj'" label="检验依据"  ><!--:rules="{required: true, message: '检验依据', trigger: ['blur', 'change']}"-->
                          <el-input maxlength="200" v-model="obj.jyyj" type="textarea" size="mini" rows="3"></el-input>
                    </el-form-item>
                    <el-row :gutter="20">
                          <el-col :span="8">
                              <el-form-item  label="检验费用（元）">
                                  <el-input-number maxlength="30"  v-trim v-model="obj.jyfy"  style="width:180px;"></el-input-number>
                              </el-form-item>
                          </el-col>
                          <el-col :span="8">
                              <el-form-item :prop="'listObj.'+objIndex+'.wcqx'" label="完成期限" :rules="{required: true, message: '完成期限', trigger: ['blur', 'change']}">
                                  <el-date-picker type="date"  v-trim v-model="obj.wcqx" value-format="yyyy-MM-dd" style="width: 180px;"></el-date-picker>
                              </el-form-item>
                          </el-col>
                          <el-col :span="8">
                              <el-form-item  label="检验时限">
                                  <el-input-number maxlength="30"  v-trim v-model="obj.limitDay"  style="width:180px;"></el-input-number> 个工作日
                              </el-form-item>
                          </el-col>
                    </el-row>
                    <el-form-item prop="" label="样品检验人员">
                        <el-table :data="obj.yjbxxjyxm"  border size="small" header-align="center"  style="width: 100%" >
                            <el-table-column  prop="inspectionStandard" label="检验标准" min-width="110px;" header-align="center" align="center" show-overflow-tooltip></el-table-column>
                            <el-table-column   prop="inspectionItemName" label="检验项目" min-width="110px;" header-align="center" align="center" show-overflow-tooltip></el-table-column>
                            <el-table-column prop="inspectorUnitId"  label="检验人员" min-width="200px">
                                <template slot-scope="scope">
                                    <el-row>
                                        <el-col :span="12">
                                            <el-form-item :prop="'listObj.'+objIndex+'.yjbxxjyxm.'+scope.$index+'.inspectorUnitId'"
                                                          :rules="{required: true, message: '部门', trigger: ['blur', 'change']}">
                                                <el-select v-model="scope.row.inspectorUnitId" @change="changeUnit(scope.$index,scope.row)" placeholder="部门" show size="mini">
                                                    <el-option v-for="map in allMap.unitOptions" :key="map.value" :label="map.label" :value="map.value"> </el-option>
                                                </el-select>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12">
                                            <el-form-item :prop="'listObj.'+objIndex+'.yjbxxjyxm.'+scope.$index+'.inspectorUserId'"
                                                          :rules="{required: true, message: '人员', trigger: ['blur', 'change']}">
                                                <el-select v-model="scope.row.inspectorUserId" @change="changeUser(scope.$index,scope.row)"
                                                           @visible-change="getUsers(scope.row)" placeholder="人员" show size="mini" multiple>
                                                    <el-option v-for="map in scope.row.itemUserOptions" :key="map.id" :label="map.username" :value="map.id"> </el-option>
                                                </el-select>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                </template>
                            </el-table-column>
                            <el-table-column prop="inspectorMethod" label="检验方法" min-width="120" header-align="center" align="center" show-overflow-tooltip></el-table-column>
                        </el-table>
                    </el-form-item>
                  </el-tab-pane>

                </template>
            </el-tabs>
        </el-form>
        <span slot="footer" class="dialog-footer">
            <el-button type="success" @click="dofpsExcel('form')">导出任务单</el-button>
            <el-button @click="fpsDialogVisible = false;formData = {}">取 消</el-button>
            <el-button type="primary" @click="dofps">分 配</el-button>
        </span>
    </el-dialog>

    <el-dialog :close-on-click-modal="false" title="选择检验项目" :visible.sync="insVisible" width="60%">
        <el-row class="header navbar bg-white" style="width: 80%">
            <div class="btn-group tool-button" style="line-height: 50px;">
                <el-input placeholder="产品名称" v-trim v-model="insPageForm.productName"  size="mini" style="width:120px;"></el-input>
                <el-input placeholder="检验依据标准" v-trim v-model="insPageForm.inspectionStandard"  size="mini" style="width:120px;"></el-input>
                <el-input placeholder="项目名称" v-trim v-model="insPageForm.inspectionItemName"  size="mini" style="width:120px;"></el-input>
                <el-button slot="append" icon="el-icon-search" size="mini" @click="insDoPage" circle></el-button>
            </div>
        </el-row>
        <el-row class="el-table-container">
            <el-table :data="insTableData"  height="300" ref="insMultipleTable"  border size="small" header-align="center"  style="width: 100%" @select-all="selectAll" @select="select">
                <el-table-column fixed="left" width="35"  type="selection"></el-table-column>
                <el-table-column prop="productName" label="产品名称" min-width="110px;" header-align="center" align="center" show-overflow-tooltip></el-table-column>
                <el-table-column prop="inspectionStandard" label="检验依据标准" min-width="110px;" header-align="center" align="center" show-overflow-tooltip></el-table-column>
                <el-table-column prop="inspectionItemName" label="检验项目" min-width="110px;" header-align="center" align="center" show-overflow-tooltip></el-table-column>
                <el-table-column prop="countUnit" label="计量单位" min-width="120" header-align="center" align="center" show-overflow-tooltip></el-table-column>
                <el-table-column   prop="inspectionPrice" label="检验费用（元）" min-width="120px;" header-align="center" align="center" show-overflow-tooltip></el-table-column>
                <el-table-column   prop="inspectionCycle" label="检验周期（天）" min-width="120px;" header-align="center" align="center" show-overflow-tooltip></el-table-column>
                <el-table-column   prop="productTypeCode" label="产品类型" min-width="110px;" header-align="center" align="center" show-overflow-tooltip>
                    <template slot-scope="scope">
                        {{getDict(scope.row.productTypeCode,allMap.yplxMap)}}
                    </template>
                </el-table-column>
                <el-table-column   prop="specification" label="规格型号" min-width="110px;" header-align="center" align="center" show-overflow-tooltip></el-table-column>
                <el-table-column   prop="sampleCount" label="样品数量" min-width="110px;" header-align="center" align="center" show-overflow-tooltip></el-table-column>
                <el-table-column   prop="chargeStandardName" label="收费标准" min-width="110px;" header-align="center" align="center" show-overflow-tooltip></el-table-column>
                <el-table-column   prop="countUnit" label="计量单位" min-width="110px;" header-align="center" align="center" show-overflow-tooltip></el-table-column>
                <el-table-column   prop="environmentStandard" label="环境要求" min-width="110px;" header-align="center" align="center" show-overflow-tooltip></el-table-column>
                <el-table-column   prop="remark" label="备注" min-width="110px;" header-align="center" align="center" show-overflow-tooltip></el-table-column>
            </el-table>
        </el-row>
        <el-row class="el-pagination-container">
            <el-pagination @size-change="insPageSizeChange" @current-change="insPageNumberChange"
                           :current-page="insPageForm.pageNumber" :page-sizes="[10, 20, 30, 50]"
                           :page-size="insPageForm.pageSize" layout="total, sizes, prev, pager, next, jumper"
                           :total="insPageForm.totalCount">
            </el-pagination>
        </el-row>
        <el-divider></el-divider>
        <el-table :data="insMultipleSelectionOld"  height="400"  border size="small" header-align="center"  style="width: 100%" >
            <el-table-column  label="操作" width="60" header-align="center" align="center">
                <template slot-scope="scope">
                    <el-button  icon="el-icon-delete" size="mini" @click="deleteSelection(scope.row)" circle></el-button>
                </template>
            </el-table-column>
            <el-table-column prop="productName" label="产品名称"  header-align="center" align="center" show-overflow-tooltip></el-table-column>
            <el-table-column prop="inspectionStandard" label="检验依据标准" min-width="90px;" header-align="center" align="center" show-overflow-tooltip></el-table-column>
            <el-table-column prop="inspectionItemName" label="检验项目" min-width="90px;" header-align="center" align="center" show-overflow-tooltip></el-table-column>
            <!--<el-table-column prop="inspectionItemOrder" label="附页序号" min-width="90px;" header-align="center" align="center" show-overflow-tooltip></el-table-column>-->
            <el-table-column prop="countUnit" label="计量单位" min-width="120" header-align="center" align="center" show-overflow-tooltip></el-table-column>
            <el-table-column prop="frequency" label="检验次数" min-width="90px;" header-align="center" align="center" show-overflow-tooltip>
                <template slot-scope="scope">
                    <el-input v-trim v-model="scope.row.frequency"  @input="scope.row.frequency=scope.row.frequency.replace(/[^\d]/g, '').replace(/^0{1,}/g,'');if(scope.row.frequency=='')scope.row.frequency=1" size="mini" style="width:100%;"></el-input>
                </template>
            </el-table-column>
            <el-table-column prop="inspectionPrice" label="原检验费用" min-width="90px;" header-align="center" align="center" show-overflow-tooltip>
            </el-table-column>
            <el-table-column prop="price" label="检验费用（元）" min-width="90px;" header-align="center" align="center" show-overflow-tooltip>
                <template slot-scope="scope">
                    <el-input v-trim v-model="scope.row.price" @input="scope.row.price=scope.row.price.replace(/[^\d^\.]+/g,'');if(scope.row.price=='')scope.row.price=0" size="mini" style="width:100%;"></el-input>
                </template>
            </el-table-column>
            <el-table-column prop="inspectionCycle" label="检验周期（天）" min-width="90px;" header-align="center" align="center" show-overflow-tooltip></el-table-column>
        </el-table>
        <span slot="footer" class="dialog-footer"><el-button @click="insVisible = false">取 消</el-button><el-button type="primary" @click="doIns">确 定</el-button></span>
    </el-dialog>
</div>
<script>
    new Vue({
        el: "#app",
        data: function () {
            var allMap = {jylxMap:${jylxMap},userOptions:{},lcztMap:${lcztMap},lzztMap:${lzztMap},unitOptions:${unitOptions},itemUserOptions:[]};
            return {
                allMap:allMap,
                tableData: [],
                menuOptions: [],
                pageForm: {lczt:'${lczt}',fpzt:"0",operation:'${operation}'},
                multipleSelection: [],
                operation:'${operation}',
                drawer: false,
                deltailURL:"",
                fpDialogVisible:false,
                fpsDialogVisible:false,
                formData:{operation:'${operation}',yjbxxjyxm:[]},
                activeName:'',

                insPageForm:{pageNumber:1,pageSize:10},
                insVisible:false,
                insTableData:[],
                insMultipleSelection:[],
                insMultipleSelectionOld:[],

                tempForm:{}

            }
        },
        methods: {
            pageOrder: function (column) {//按字段排序
                this.pageForm.pageOrderName = column.prop;
                this.pageForm.pageOrderBy = column.order;
                this.pageData();
            },
            pageNumberChange: function (val) {//页码更新操作
                this.pageForm.pageNumber = val;
                this.pageData();
            },
            pageSizeChange: function (val) {//分页大小更新操作
                this.pageForm.pageSize = val;
                this.pageData();
            },
            pageData: function () {//加载分页数据
                var self = this;
                sublime.showLoadingbar();//显示loading
                $.post(base + "/platform/bus/rwgl/data", self.pageForm, function (data) {
                    sublime.closeLoadingbar();//关闭loading
                    if (data.code == 0) {
                        self.tableData = data.data.list;
                        self.pageForm.totalCount = data.data.totalCount;
                    } else {
                        self.$message({
                            message: data.msg,
                            type: 'error'
                        });
                    }
                }, "json");
            },
            doSearch: function () {
                this.pageForm.pageNumber = 1;
                this.pageData();
            },
            getDict: function (val,map) {
                if (val!= null && val!=undefined &&val!="" &&val!="null" &&val!="undefined" && map!=null && map !=undefined){
                    var str = val.split(",");
                    var strname="";
                    for (var a=0;a<str.length;a++){
                        strname+=map[str[a]];
                        if(strname == null){
                            alert(1)
                        }
                        if(a<(str.length-1)){
                            strname+="/";
                        }
                    }
                    return strname;
                }
                return "";
            },
            async getTofp(datas){
                var self = this;
                self.formData=JSON.parse(JSON.stringify(datas));
                await self.resetForm()
                await self.getListObjUser(datas)
                self.formData=JSON.parse(JSON.stringify(datas));
                self.fpDialogVisible = true;//打开窗口
            },
            async resetForm() {
                //console.log(this.formData.yjbxxjyxm)
                if(this.formData.yjbxxjyxm){
                    this.formData.yjbxxjyxm.forEach(item =>{
                        Object.keys(item).forEach(key => {
                            //const initialType = typeof this.formData[key]
                            const currentValue = item[key]
                            if (key==='inspectorUserId' && Array.isArray(currentValue)) {
                                this.$set(item, key, currentValue.join(','))
                            }
                        })
                    })
                }
                //this.formData= {};

                //console.log(this.formData)
            },

            async dropdownCommand(command) {
                var self = this;
                if ("tofp" == command.type) {
                    await self.resetForm()
                    //self.formData= {}
                    sublime.showLoadingbar();//显示loading
                    $.post(base + "/platform/bus/rwgl/tofp/"+command.id, {}, function (data) {
                        sublime.closeLoadingbar();//关闭loading
                        if (data.code == 0) {
                            const datas = {}
                            datas.id = command.id;//加载后台表单数据
                            datas.ypbh = data.data.obj.ypbh;
                            datas.yplx = data.data.obj.yplx;
                            datas.jyxm = data.data.obj.jyxm;
                            datas.jyyj = data.data.obj.jyyj;
                            datas.jyfy = data.data.obj.jyfy;
                            datas.wcqx = data.data.obj.wcqx;
                            datas.limitDay = data.data.obj.limitDay;
                            self.allMap.userOptions=data.data.userOptions;
                            datas.yjbxxjyxm = data.data.obj.yjbxxjyxm;
                            if(data.data.users){
                                datas.nextsprIds = data.data.users.split(",");
                                //self.formData.jyryIds = data.data.users.split(",");
                            }
                            self.getTofp(datas)
                        } else {
                            self.$message({
                                message: data.msg,
                                type: 'error'
                            });
                        }
                    }, "json");
                }
                if ("torl" == command.type) {
                    await self.resetForm()
                    //self.formData= {}
                    //window.location.href="/platform/bus/rwgl/torl/"+command.id;
                    //补充流程信息
                    self.formData.jbxxId = command.id;
                    self.formData.ypbh = command.ypbh;
                    self.formData.id = "";
                    self.formData.lczt = "2";
                    self.formData.nextspr = "${username}";
                    self.formData.nextsprIds = "${userId}";
                    self.formData.jyry = "${username}";
                    self.formData.jyryIds = "${userId}";
                    self.formData.spyj = "";
                    self.formData.operation = self.operation;
                    self.$confirm('此操作将认领 ' + command.ypbh, '提示', {
                            confirmButtonText: '确定',
                            cancelButtonText: '取消',
                            type: 'warning',
                            callback: function (a, b) {
                                if ("confirm" == a) {//确认后再执行
                                    sublime.showLoadingbar();//显示loading
                                    $.post(base + "/platform/bus/rwgl/rwglDo", self.formData, function (data) {
                                        sublime.closeLoadingbar();//关闭loading
                                        if (data.code == 0) {
                                            self.$message({
                                                message: data.msg,
                                                type: 'success'
                                            });
                                            self.doSearch();//查询是带条件的,加载新建用户选择的数据
                                        } else {
                                            self.$message({
                                                message: data.msg,
                                                type: 'error'
                                            });
                                        }
                                    }, "json");
                                }
                            }
                    });
                }
                if ("toch" == command.type) {
                    //window.location.href="/platform/bus/rwgl/toch/"+command.id;
                    //补充流程信息
                    await self.resetForm()
                    //self.formData= {}
                    self.formData.jbxxId=command.id;
                    self.formData.ypbh = command.ypbh;
                    self.formData.id="";
                    self.formData.lczt="3";
                    self.formData.spyj="";
                    self.formData.operation = self.operation;
                    self.$confirm('此操作将撤回 ' + command.ypbh, '提示', {
                            confirmButtonText: '确定',
                            cancelButtonText: '取消',
                            type: 'warning',
                            callback: function (a, b) {
                                if ("confirm" == a) {//确认后再执行
                                    sublime.showLoadingbar();//显示loading
                                    const data = JSON.parse(JSON.stringify(self.formData));
                                    data.operation="rwch"
                                    $.post(base + "/platform/bus/rwgl/rwglDo", data, function (data) {
                                        sublime.closeLoadingbar();//关闭loading
                                        if (data.code == 0) {
                                            self.$message({
                                                message: data.msg,
                                                type: 'success'
                                            });
                                            self.doSearch();//查询是带条件的,加载新建用户选择的数据
                                        } else {
                                            self.$message({
                                                message: data.msg,
                                                type: 'error'
                                            });
                                        }
                                    }, "json");
                                }
                            }
                    });

                }
                if ("detail" == command.type) {
                    this.drawer=true;
                    this.deltailURL="/platform/bus/ypxx/jbxx/detail/"+command.id;
                }
                if ("createCirculation" == command.type) {
                    sublime.showLoadingbar();//显示loading
                    $.post(base + "/platform/bus/ypxx/transfer/createCirculation/" + command.id, {}, function (data) {
                        sublime.closeLoadingbar();//关闭loading
                        if (data.code == 0) {
                            self.$message({
                                message: data.msg,
                                type: 'success'
                            });
                            self.drawer = true;
                            var WOPISrc = "${AppDomain!}/platform/wopi/files/" + command.id + "lzd.docx";
                            self.deltailURL = "${AppOfficeDomain!}/wv/wordviewerframe.aspx?wdAccPdf=1&WOPISrc=" + WOPISrc+"&_="+Math.floor(Math.random()*100000);
                        } else {
                            self.$message({message: data.msg,type: 'error'});
                        }
                    }, "json");
                }
            },
            openIframe:function(){
                $("#iframeDetail").attr("src",this.deltailURL);
            },
            handleClose: function() {
                this.drawer=false;
            },
            dofp:function(){
                var self = this;
                self.$refs["fpForm"].validate(function (valid) {
                    if (valid) {
                        if(nONull(self.formData.nextsprIds)){
                            self.formData.nextspr = "";
                            for(var i =0 ;i<self.formData.nextsprIds.length;i++){
                                self.formData.nextspr += self.$refs['nextsprCascader'].getCheckedNodes()[i].label;
                                if(i<(self.formData.nextsprIds.length -1 )){
                                    self.formData.nextspr +=",";
                                }
                            }
                        }else{
                            //self.$message({message: "请选择报告编制人员!",type: 'warning'});
                            //return false;
                        }
                        /*if(nONull(self.formData.jyryIds)){
                            self.formData.jyry = "";
                            for(var i =0 ;i<self.formData.jyryIds.length;i++){
                                self.formData.jyry += self.$refs['jyryCascader'].getCheckedNodes()[i].label;
                                if(i<(self.formData.jyryIds.length -1 )){
                                    self.formData.jyry +=",";
                                }
                            }
                        }else{
                            self.$message({message: "请选择样品检验人员!",type: 'warning'});
                            return false;
                        }*/
                        //self.formData.jyryIds=self.formData.jyryIds.join(",");
                        //补充流程信息
                        self.formData.jbxxId=self.formData.id;
                        self.formData.id="";
                        self.formData.lczt="2";
                        /*if(!nONull(self.formData.spyj)){
                            //self.formData.spyj="任务分配";
                        }*/
                        self.formData.operation = self.operation;
                        sublime.showLoadingbar();//显示loading
                        var data = JSON.parse(JSON.stringify(self.formData));
                        data.nextsprIds=data.nextsprIds.join(",");
                        data.yjbxxjyxm.forEach(item =>{
                            if(nONull(item.inspectorUserId)){
                                item.inspectorUserId = item.inspectorUserId.join(",")
                                item.inspectorUserName=item.itemUserOptions.filter(itemuser => item.inspectorUserId.includes(itemuser.id))
                                    .map(itemuser => itemuser.username).join("、");
                            }
                        })
                        data.yjbxxjyxm = JSON.stringify(data.yjbxxjyxm)
                        $.post(base + "/platform/bus/rwgl/rwglDo",data, function (data) {
                            sublime.closeLoadingbar();//关闭loading
                            if (data.code == 0) {
                                self.$message({
                                    message: data.msg,
                                    type: 'success'
                                });
                                self.fpDialogVisible = false;
                                self.doSearch();//查询是带条件的,加载新建用户选择的数据
                            } else {
                                self.$message({
                                    message: data.msg,
                                    type: 'error'
                                });
                            }
                        }, "json");
                    }
                });
            },
            handleSelectionChange: function (val) {
                this.multipleSelection = val;
            },
            getDay(day,index){
                if(day){
                    const today = new Date();
                    const inputDate = new Date(day);
                    const diffTime = inputDate-today;
                    const diffDays = Math.abs((diffTime / (1000 * 60 * 60 * 24)).toFixed(0));
                    if(diffTime<0&&diffDays>0){
                        $("#foot"+index).css("color","red");
                        return "逾期："+diffDays+"天";
                    }else{
                        return "剩余："+diffDays+"天";
                    }
                }else{
                    return "";
                }
            },
            changeUnit:function (index,obj){
                var self =this ;
                const unit=self.allMap.unitOptions.find((item)=>{return item.value === obj.inspectorUnitId;});
                obj.inspectorUnitName = unit.label;
                obj.inspectorUserId=[]
                //self.getUsers(obj.inspectorUnitId)
            },
            async getUsers(obj){
                var self = this;
                await self.getItemUserOptionsByUnitId(obj);
                self.formData = JSON.parse(JSON.stringify(self.formData));
            },
            async getItemUserOptionsByUnitId(item){
                var self =this ;
                if(nONull(item.inspectorUnitId)){
                    return new Promise((resolve,reject) =>{
                        $.post(base + "/platform/sys/user/getUsersByUnit", {unitId:item.inspectorUnitId}, function (data) {
                            if (data.code == 0) {
                                item.itemUserOptions = data.data;
                                //console.log("===================",JSON.parse(JSON.stringify(item)))
                            } else {
                                item.itemUserOptions = undefined;
                                self.$message({message: data.msg,type: 'error'});
                            }
                            resolve(item)
                        }, "json");
                    })
                }else{
                    item.itemUserOptions = undefined;
                }

            },
            changeUser:function (index,obj){
                /*var self =this ;
                const user=self.allMap.itemUserOptions.find((item)=>{return item.id === obj.inspectorUserId;});
                obj.inspectorUserName = user.username;*/
                obj.inspectorUserName=obj.itemUserOptions.filter(item => obj.inspectorUserId.includes(item.id)).map(item => item.username).join("、");
            },
            showFprq:function(){
                if(this.pageForm.fpzt=="0"){
                    this.pageForm.fprqsk=undefined;
                    this.pageForm.fprqsj=undefined;
                }
                this.$refs.multipleTable.clearSelection()
                this.pageData();
            },
            async resetPlForm() {
                //console.log(this.formData.yjbxxjyxm)
                if(this.formData.listObj){
                    this.formData.listObj.forEach(obj =>{
                        /*Object.keys(obj).forEach(key => {
                            //const initialType = typeof this.formData[key]
                            const currentValue = item[key]
                            if (key === 'nextsprIds' && Array.isArray(currentValue)) {
                                this.$set(item, key, currentValue.join(','))
                            }
                        })*/
                        if(obj.yjbxxjyxm) {
                            obj.yjbxxjyxm.forEach(item => {
                                Object.keys(item).forEach(key => {
                                    //const initialType = typeof this.formData[key]
                                    const currentValue = item[key]
                                    if (key === 'inspectorUserId' && Array.isArray(currentValue)) {
                                        this.$set(item, key, currentValue.join(','))
                                    }
                                })
                            })
                        }
                    })
                }
                //this.formData= {};

                //console.log(this.formData)
            },
            //批量分配
            async tofps(){
                var self =this ;
                if(self.multipleSelection.length==0){
                    self.$message({message: '未选择需要分配的样品！',type: 'error'});
                    return;
                }
                var ids = "'"+self.multipleSelection.map(t => t.id).join("','")+"'"
                //console.log(ids)
                await self.resetPlForm();
                //self.formData= {}
                sublime.showLoadingbar();//显示loading
                $.post(base + "/platform/bus/rwgl/tofps/", {ids:ids}, function (data) {
                    sublime.closeLoadingbar();//关闭loading
                    if (data.code == 0) {
                        self.getEdit(data.data)
                    } else {
                        self.$message({
                            message: data.msg,
                            type: 'error'
                        });
                    }
                }, "json");
            },
            async getEdit(data){
                var self = this;
                const datas = JSON.parse(JSON.stringify(data));//加载后台表单数据
                if(datas.length>0){
                    self.activeName = datas[0].ypbh
                }
                const promises =   datas.map(async item=>{
                    if(item.users){
                        item.nextsprIds = item.users.split(",");
                    }
                    await self.getListObjUser(item)
                })
                try {
                    sublime.showLoadingbar();//显示loading
                    await Promise.all(promises);
                    sublime.closeLoadingbar();//关闭loading
                } catch (error) {
                    console.error('Error fetching data:', error);
                }
                self.formData.listObj = JSON.parse(JSON.stringify(datas));//加载后台表单数据
                await self.resetPlForm();
                self.formData.listObj = JSON.parse(JSON.stringify(datas));//加载后台表单数据
                self.formData.jypc = sublime.formatDate(new Date());//加载后台表单数据
                self.formData = JSON.parse(JSON.stringify(self.formData))
                self.fpsDialogVisible = true;//打开窗口
            },
            async getListObjUser(item){
                var self = this;
                await Promise.all( item.yjbxxjyxm.map(async itemjyxm =>{
                        await self.getItemUserOptionsByUnitId(itemjyxm);
                        if(nONull(itemjyxm.inspectorUserId)){
                            itemjyxm.inspectorUserId = itemjyxm.inspectorUserId.split(",")
                        }
                    })
                )
            },
            tochs:function(){
                var self =this ;
                if(self.multipleSelection.length==0){
                    self.$message({message: '未选择需要撤回的样品！',type: 'error'});
                    return;
                }
                self.formData= {listObj:[]};
                var ypbhs =self.multipleSelection.map(t => t.ypbh).join(",")
                self.multipleSelection.forEach(item=>{
                    const listObj = {}
                    listObj.jbxxId = item.id;
                    listObj.ypbh = item.ypbh;
                    listObj.id="";
                    listObj.lczt="3";
                    listObj.spyj="";
                    self.formData.listObj.push(listObj)
                })
                self.formData.operation = self.operation;
                self.$confirm('此操作将撤回 ' + ypbhs, '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning',
                    callback: function (a, b) {
                        if ("confirm" == a) {//确认后再执行
                            sublime.showLoadingbar();//显示loading
                            $.post(base + "/platform/bus/rwgl/rwglDos", {listObj : JSON.stringify(self.formData.listObj),operation:'rwch'}, function (data) {
                                sublime.closeLoadingbar();//关闭loading
                                if (data.code == 0) {
                                    self.$message({message: data.msg,type: 'success'});
                                    self.$refs.multipleTable.clearSelection()
                                    self.multipleSelection=[]
                                    self.doSearch();//查询是带条件的,加载新建用户选择的数据
                                } else {
                                    self.$message({message: data.msg,type: 'error'});
                                }
                            }, "json");
                        }
                    }
                });
            },
            getNextsprs:function(obj){
                if(nONull(obj.nextsprIds)){
                    const ids = obj.nextsprIds.join(",").split(",")
                    obj.nextspr = obj.userOptions.filter((item)=>ids.includes(item.value)).map(item => item.label)
                    //console.log(obj)
                }
            },
            dofps:function(){
                var self = this;
                self.$refs["fpsForm"].validate(function (valid) {
                    if (valid) {
                        var listObj = JSON.parse(JSON.stringify(self.formData.listObj))
                        //补充流程信息
                        listObj.forEach(item=>{
                            item.id="";
                            item.lczt="2";
                            if(nONull(item.nextspr)){item.nextspr = item.nextspr.join(",");}
                            if(nONull(item.nextsprIds)){item.nextsprIds=item.nextsprIds.join(",");}
                            item.spyj=self.formData.spyj;
                            item.yjbxxjyxm.forEach(itemjyxm =>{
                                if(nONull(itemjyxm.inspectorUserId)){
                                    itemjyxm.inspectorUserId = itemjyxm.inspectorUserId.join(",")
                                    itemjyxm.inspectorUserName=itemjyxm.itemUserOptions.filter(itemuser => itemjyxm.inspectorUserId.includes(itemuser.id))
                                        .map(itemuser => itemuser.username).join("、");
                                }
                            })
                        })
                        sublime.showLoadingbar();//显示loading
                        $.post(base + "/platform/bus/rwgl/rwglDos",{listObj : JSON.stringify(listObj),operation:self.operation,jypc:self.formData.jypc}, function (data) {
                            sublime.closeLoadingbar();//关闭loading
                            if (data.code == 0) {
                                self.$message({message: data.msg,type: 'success'});
                                self.$refs.multipleTable.clearSelection()
                                self.multipleSelection=[]
                                self.fpsDialogVisible = false;
                                self.doSearch();//查询是带条件的,加载新建用户选择的数据
                            } else {
                                self.$message({message: data.msg,type: 'error'});
                            }
                        }, "json");
                    }else{
                        self.$message({message: '存在未填写数据！',type: 'error'});
                    }
                });
            },
            handleTabsEdit:function(targetName, action){
                if (action === 'remove') {
                    this.formData.listObj = this.formData.listObj.filter(tab => tab.ypbh !== targetName);
                }
            },
            checkSelect:function(row,index){
                let isChecked = true;
                if (row.lczt>4) { // 判断里面是否存在某个参数
                    isChecked = false
                } else {
                    isChecked = true
                }
                return isChecked
            },
            dofpsExcel:function(type){
                var self = this;
                var params = {};
                if(type=='form'){
                    var listObj = JSON.parse(JSON.stringify(self.formData.listObj))
                    //补充流程信息
                    listObj.forEach(item=>{
                        self.$delete(item,"userOptions")
                        if(nONull(item.nextspr)){item.nextspr = item.nextspr.join(",");}
                        if(nONull(item.nextsprIds)){item.nextsprIds=item.nextsprIds.join(",");}
                        item.yjbxxjyxm.forEach(itemjyxm =>{
                            if(nONull(itemjyxm.inspectorUserId)){
                                itemjyxm.inspectorUserId = itemjyxm.inspectorUserId.join(",")
                                itemjyxm.inspectorUserName=itemjyxm.itemUserOptions.filter(itemuser => itemjyxm.inspectorUserId.includes(itemuser.id))
                                    .map(itemuser => itemuser.username).join("、");
                            }
                            self.$delete(itemjyxm,"itemUserOptions")
                        })
                    })
                    console.log(listObj)
                    params = {listObj : JSON.stringify(listObj),}
                }
                if(type=='all'){
                    if(self.multipleSelection.length>0){
                        const ids = self.multipleSelection.map(t => t.id)
                        params = {ids:ids};
                    }else{
                        params = self.pageForm
                        console.log(params)
                    }
                }
                this.downloadExcelWithList('/platform/bus/rwgl/export',params);
            },
            downloadExcelWithList:function(url, params){
                var xhr = new XMLHttpRequest();
                xhr.open('POST', base + url);
                xhr.responseType = 'blob';
                xhr.onload = function() {
                    if (xhr.status === 200) {
                        var blob = xhr.response;
                        var filename = xhr.getResponseHeader('content-disposition')?.split('filename=')[1] || 'download.xlsx';
                        //var contentDisposition = xhr.getResponseHeader('content-disposition');
                        filename = decodeURIComponent(filename);
                        var url = window.URL.createObjectURL(blob);
                        var a = document.createElement('a');
                        a.href = url;
                        a.download = filename.replace(/["']/g, '');
                        a.click();
                        window.URL.revokeObjectURL(url);
                    } else {
                        console.error('下载失败:', xhr.status);
                    }
                };
                xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;charset=UTF-8');
                xhr.onerror = function() {
                    console.error('请求失败');
                };
                var self = this;
                var encodedParams = new URLSearchParams(params).toString();
                xhr.send(encodedParams);
            },


            openIns:function(obj){
                this.tempForm = obj;
                this.insVisible=true;
                this.insPageForm.pageNumber = 1;
                this.insPageForm.pageSize = 10;
                this.insMultipleSelectionOld=JSON.parse(JSON.stringify(obj.yjbxxjyxm));
                this.insDoSearch();
            },
            insPageNumberChange: function (val) {//页码更新操作
                this.insPageForm.pageNumber = val;
                this.insDoSearch();
            },
            insPageSizeChange: function (val) {//分页大小更新操作
                this.insPageForm.pageSize = val;
                this.insDoSearch();
            },
            insDoPage: function () {
                this.insPageForm.pageNumber = 1;
                this.insDoSearch();
            },
            insDoSearch:function(){
                var self = this;
                if(nONull(self.tempForm.yplx)){self.insPageForm.yplx=self.tempForm.yplx;}
                sublime.showLoadingbar();//显示loading
                $.post(base + "/platform/bus/ypxx/jbxx/getInsData", self.insPageForm, function (data) {
                    sublime.closeLoadingbar();//关闭loading
                    if (data.code == 0) {
                        //self.insTableData = self.insTableData.concat(data.data.list);
                        self.insTableData = data.data.list;
                        self.insPageForm.totalCount = data.data.totalCount;
                        console.log(self.insTableData)
                        console.log(self.insMultipleSelectionOld)
                        //已选择项带入
                        if (self.insMultipleSelectionOld.length > 0) {
                            self.$nextTick(function () {
                                self.insMultipleSelectionOld.forEach(function(item) {
                                    self.insTableData.forEach(function(listitem){
                                        if (item.insItemId == listitem.insItemId) {
                                            self.$refs.insMultipleTable.toggleRowSelection(listitem, true)
                                        }
                                    })
                                })
                            })
                        }
                    } else {
                        self.$message({
                            message: data.msg,
                            type: 'error'
                        });
                    }
                }, "json");
            },
            selectAll: function (val) {
                this.insMultipleSelection = val;
                var self = this;
                //self.insMultipleSelectionOld = self.multipleSelection;
                //塞入选择的项
                if(self.insMultipleSelection.length>0){
                    self.insMultipleSelection.forEach(function(itemNew){
                        var a = true;
                        self.insMultipleSelectionOld.forEach(function(itemOld) {
                            if (itemOld.insItemId == itemNew.insItemId) {
                                a=false;
                                return;
                            }
                        })
                        if(a){
                            self.insMultipleSelectionOld.push(itemNew);
                        }
                    })
                }else{
                    self.insTableData.forEach(function(itemTable){
                        self.insMultipleSelectionOld.forEach(function(itemOld2,i) {
                            if (itemOld2.insItemId == itemTable.insItemId) {
                                self.insMultipleSelectionOld.splice(i,1)
                                return;
                            }
                        })
                    })
                }
            },
            select: function (val,index) {
                this.insMultipleSelection = val;
                var self = this;
                //self.insMultipleSelectionOld = self.multipleSelection;
                //塞入选择的项
                var b = true ;
                self.insMultipleSelection.forEach(function(itemNew){
                    if (index.insItemId == itemNew.insItemId) {
                        var a = true;
                        self.insMultipleSelectionOld.forEach(function(itemOld) {
                            if (itemOld.insItemId == index.insItemId) {
                                a=false;
                                return;
                            }
                        })
                        if(a){
                            self.insMultipleSelectionOld.push(itemNew);
                        }
                        b = false ;
                        return;
                    }
                })
                if(b){
                    self.insMultipleSelectionOld.forEach(function(itemOld2,i) {
                        if (itemOld2.insItemId == index.insItemId) {
                            self.insMultipleSelectionOld.splice(i,1);
                            return;
                        }
                    })
                }

            },
            deleteSelection:function(scope){
                var self = this;
                self.insMultipleSelection.forEach(function(itemNew,i){
                    if (itemNew.insItemId == scope.insItemId) {
                        self.insMultipleSelection.splice(i,1);
                        self.$refs.insMultipleTable.toggleRowSelection(itemNew, false)
                    }
                })
                self.insMultipleSelectionOld.forEach(function(itemOld,i) {
                    if (itemOld.insItemId == scope.insItemId) {
                        self.insMultipleSelectionOld.splice(i,1);
                    }
                })

            },
            doIns: function () {
                var self = this;
                if (self.insMultipleSelectionOld.length > 0) {
                    var inspectionItemNames = "";
                    var inspectionStandards = [];
                    var inspectionStandardstr = "";
                    var prices = 0 ;
                    var inspectionCycles = 0;
                    self.insMultipleSelectionOld.forEach(function (val) {
                        inspectionItemNames += val.inspectionItemName + "，";
                        var a = true;
                        inspectionStandards.forEach(function(ins){
                            if (ins == val.inspectionStandard) {
                                a = false;
                            }
                        })
                        if(a){
                            inspectionStandards.push(val.inspectionStandard);
                            inspectionStandardstr += val.inspectionStandard+"，";
                        }
                        if(nONull(val.price))
                            prices +=parseFloat(val.price);
                        if(nONull(val.inspectionCycle))
                            inspectionCycles+=parseFloat(val.inspectionCycle);
                    });
                    inspectionItemNames = inspectionItemNames.substring(0,(inspectionItemNames.length-1));
                    self.tempForm.jyxm = inspectionItemNames;


                    inspectionStandardstr = inspectionStandardstr.substring(0,(inspectionStandardstr.length-1));
                    self.tempForm.jyyj = inspectionStandardstr;
                    self.tempForm.jyfy=prices;
                    self.tempForm.limitDay = inspectionCycles;
                    self.tempForm.yjbxxjyxm = self.insMultipleSelectionOld;
                    self.tempForm = JSON.parse(JSON.stringify(self.tempForm))
                    self.insVisible=false;
                }else{
                    self.$message({message: '请选择检验项目！',type: 'warning'});
                    return ;
                }
            },
        },
        created: function () {
            this.doSearch();
        }
    });

    function nONull(val){
        if (val!= null && val!=undefined &&val!="" &&val!="null" &&val!="undefined" ){
            return true;
        }else{
            return false;
        }
    }
</script>
<!--#
}
#-->
